/*************************************************************************
	> File Name: P2386.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-09 16:14:28
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 10

int f[MAX_N + 5][MAX_N + 5];

int main() {
    for (int i = 1; i <= MAX_N; i++) {
        f[0][i] = 1;
        f[1][i] = 1;
    }
    for (int i = 1; i <= MAX_N; i++) {
        f[i][1] = 1;
    }
    for (int i = 2; i <= MAX_N; i++) {
        for (int j = 2; j <= MAX_N; j++) {
            if (i < j) {
                f[i][j] = f[i][i];
            } else {
                f[i][j] = f[i - j][j] + f[i][j - 1];
                //对于每次一次都有两种做法：
                //1：j个盘子都放1个，即：f[i - j][j]
                //2: 都不放，即：f[i][j - 1]
            }
        }
    }
    int t;
    cin >> t;
    while (t--) {
        int m, n;
        cin >> m >> n;
        cout << f[m][n] << endl;
    }
    return 0;
}
